﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewPOProcess.aspx.cs" Inherits="POProcess.NewPOProcess" %>

<%@ Register Src="../../Processes/ProcessControl/ButtonList.ascx" TagName="buttonlist"
    TagPrefix="btn" %>
<%@ Register Src="../../Processes/ProcessControl/ApprovalHistory.ascx" TagName="approvalhistory"
    TagPrefix="ah" %>
<%@ Register Src="../../Processes/ProcessControl/Attachments.ascx" TagName="attachments"
    TagPrefix="attach" %>
<%@ Register Src="../../Processes/ProcessControl/UserInfo.ascx" TagName="userinfo"
    TagPrefix="ui" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Purchasing Order采购单</title>
    <script type="text/javascript" src="../../js/jquery-1.4.2.min.js" charset="gb2312"></script>
    <script src="../../js/jquery-ui-1.8.4.custom.min.js" type="text/javascript" charset="gb2312"></script>
    <script src="../../js/jquery.js" type="text/javascript"></script>
    <script src="../../js/common.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        setInterval("IsOverspend()", 200);  //定时判断当前用户输入的金额是否超出PR的金额。

        function selectNewPage(sql, order, displayField, displayFieldCaption, displayFieldWidth, title) {
            str = "/../../Modules/Portal/NewSelectPage.aspx?sql=" + sql + "&order=" + order + "&query=" + displayField + "&caption=" + displayFieldCaption + "&width=" + displayFieldWidth + "&title=" + title;
            str = encodeURI(str);
            val = window.showModalDialog(str, null, "scroll:1;status:0;help:0;dialogWidth=800px;dialogHeight=480px");
            if (val) {
                return val;
            }
            return null;
        }

        //选择弹出页面
        function selectPage1() {
            var RadioCheck = $("input[name='Type']:checked").val();   //类型：Capex类和费用类             
            if (RadioCheck) {
                var dpt = $("[id$=fld_DEPARTMENT]").text();    //部门信息
                var CostCenter = $("[id$=fld_COSTCENTER]").text();   //成本中心    
                var ApplicantAccount = $("#UserInfo1_txtApplicantAccount").val();   //当前申请人
                //alert(ApplicantAccount);         
                //rtn = selectPage("select distinct P.FORMID,P.DOCUMENTNO,P.APPLICANT,P.COSTCENTER,P.PRODUCTLINE,P.REQUESTDATE,P.CATAGARY,P.SUBCATAGARY from PROC_PURCHASEREQUEST as P inner join dbo.PROC_PURCHASEREQUEST_DT as T on T.FORMID=P.FORMID where P.DEPARTMENT='" + dpt + "' and P.STATUS=2 and  T.STATUS=0 ", "DOCUMENTNO", "DOCUMENTNO,APPLICANT,COSTCENTER,PRODUCTLINE,REQUESTDATE", "PR单号,PR申请人,成本中心,项目号,申请时间", "50,40,50,50,50", "选择PR数据");
                if (RadioCheck == "fld_EXPENSETYPE") {
                    rtn = selectNewPage("select distinct P.FORMID,P.DOCUMENTNO,P.APPLICANT,P.COSTCENTER,P.PRODUCTLINE,P.REQUESTDATE,P.CATAGARY,P.SUBCATAGARY,P.EXPENSETYPE from PROC_PURCHASEREQUEST as P inner join dbo.PROC_PURCHASEREQUEST_DT as T on T.FORMID=P.FORMID where P.STATUS=2 and  T.STATUS=0  and P.MROBUYER='" + ApplicantAccount + "' and P.EXPENSETYPE='1'", "DOCUMENTNO", "DOCUMENTNO,APPLICANT,COSTCENTER,PRODUCTLINE,REQUESTDATE", "PR单号,PR申请人,成本中心,项目号,申请时间", "50,40,50,50,50", "选择费用类PR数据");
                    if (rtn) {
                        $("#fld_PONO").val(rtn.DOCUMENTNO);
                        $("#fld_PRFORMID").val(rtn.FORMID);
                        //$("#fld_CATEGORY").val(rtn.CATAGARY.replace("&nbsp;", ""));
                        //$("#fld_SUBCATEGORIES").val(rtn.SUBCATAGARY.replace("&nbsp;", ""));
                        $("#fld_PROJECTNUMBER").val(rtn.PRODUCTLINE);
                        if (rtn.FORMID == null || rtn.FORMID == undefined) {
                            GetJason(rtn.DOCUMENTNO);
                        }
                    }
                }
                else {
                    rtnCapex = selectPage("select distinct P.FORMID,P.DOCUMENTNO,P.APPLICANT,P.COSTCENTER,P.PRODUCTLINE,P.REQUESTDATE,P.CATAGARY,P.SUBCATAGARY,P.CAPEXTYPE from PROC_PURCHASEREQUEST as P inner join dbo.PROC_PURCHASEREQUEST_DT as T on T.FORMID=P.FORMID where P.STATUS=2 and  T.STATUS=0 and P.MROBUYER='" + ApplicantAccount + "' and P.CAPEXTYPE='1'", "DOCUMENTNO", "DOCUMENTNO,APPLICANT,COSTCENTER,PRODUCTLINE,REQUESTDATE", "PR单号,PR申请人,成本中心,项目号,申请时间", "50,40,50,50,50", "选择固定资产类PR数据");
                    if (rtnCapex) {
                        $("#fld_PONO").val(rtnCapex.DOCUMENTNO);
                        $("#fld_PRFORMID").val(rtnCapex.FORMID);
                        $("#fld_CATEGORY").val(rtnCapex.CATAGARY.replace("&nbsp;", ""));
                        $("#fld_SUBCATEGORIES").val(rtnCapex.SUBCATAGARY.replace("&nbsp;", ""));
                        $("#fld_PROJECTNUMBER").val(rtnCapex.PRODUCTLINE);
                    }
                }
                JavaScript: __doPostBack('lnk_LoadPayMent', '');
            }
            else {
                alert("Please Select The Type Of / 请选择类型");
            }
            return false;
        }
        //选择弹出页面
        function selectPage2() {
            //rtn = selectPage("SELECT SUPPLIERNO,SUPPLIERNAME,SUPPLIERTEL,CONTACT,SUPPLIEREMAIL FROM SYNC_SUPPLIER", "SUPPLIERNAME", "SUPPLIERNO,SUPPLIERNAME,SUPPLIERTEL,CONTACT,SUPPLIEREMAIL", "供应商编号,供应商名称,供应商电话,联系人,电子邮件", "50,20", "选择供应商数据");
            rtn = selectPage("select vd_addr,ad_name,ad_phone,ad_attn,vd_buyer from SYNC_SUPPLIERINFORMATION", "", "vd_addr,ad_name,ad_phone,ad_attn,vd_buyer", "供应商编号,供应商名称,供应商电话,联系人,采购员", "20,50,20,20,20", "选择供应商数据");
            if (rtn) {
                $("#fld_SUPPLIERNUMBER").val(rtn.vd_addr.replace("&nbsp;", ""));
                $("#fld_SUPPLIERNAME").val(rtn.ad_name.replace("&nbsp;", ""));
                $("#fld_SUPPLIERPHONE").val(rtn.ad_phone.replace("&nbsp;", ""));
                $("#fld_CONTACT").val(rtn.ad_attn.replace("&nbsp;", ""));
                $("#fld_SUPPLIEREMAIL").val();
                //$("#fld_BUYER").val(rtn.vd_buyer.replace("&nbsp;", ""))
            }
            JavaScript: __doPostBack('lnk_LoadPayMent', '');
            return false;
        }
        function Check_PONO() {
            //            if ($("#fld_PONO").val() != "") {
            //                var TaxableSelectValue = $("#fld_TAXABLE").val();   //应纳税的选中值
            //                var TaxSelectValue = $("#fld_TAXCATEGORY").val();   //税别的选中值               
            //                SetTaxableValue(TaxableSelectValue);
            //                SetTaxValue(TaxSelectValue);
            //            }
            //            else {
            //                alert("请先选择PR单号！");
            //                return false;
            //            }    
            if ($("#fld_PONO").val() == "") {
                alert("Please Select PR Number/请先选择PR单号！");
                return false;
            }
            if (ResultCou == 1) {
                return false;
            }
        }
        function TotalAmount() {
            var Sum_JE = 0;
            $("#tbDetail tr:gt(0)").each(function (i, Etr) {
                var JE = $(Etr).find("td:eq(12)").children().val() - 0;
                if (!isNaN(JE)) {
                    Sum_JE += JE;
                }
                else {
                    $(Etr).find("td:eq(12)").children().val("");
                }
            });
            $("#var_AMOUNT").val(Sum_JE.toFixed(2));
            $("#fld_TOTALAMOUNT").val(Sum_JE.toFixed(2));
        }
        function getSumJE() {
            var Sum_JE;
            $("#tbDetail tr:gt(0)").each(function (i, Etr) {
                var JE = $(Etr).find("td:eq(9)").children().val() - 0;
                var JF = $(Etr).find("td:eq(11)").children().val() - 0;
                Sum_JE = parseFloat(JE) * parseFloat(JF);
                $(Etr).find("td:eq(12)").children().val(Sum_JE.toFixed(2))
            });
            TotalAmount();
        }
        $().ready(function () {
            InitDivDialogs();   //初始化Div层

            //var TaxableSelectValue = $("#fld_TAXABLE").val();   //应纳税的选中值
            //var TaxSelectValue = $("#fld_TAXCATEGORY").val();   //税别的选中值
            //SetTaxableValue(TaxableSelectValue);
            //SetTaxValue(TaxSelectValue);

            //获取付款方式名称
            var ddlSelectValue = $("#fld_PAYMENT").find("option:selected").val();  //付款方式
            GetPaymentName(ddlSelectValue);

            $("#hfResult").val("0");  //设置隐藏控件初始值为0

            //获取当前流程名
            var CurrentProcessName = $("#UserInfo1_fld_PROCESSNAME").val();
            //获取上传附件时需要的附件名
            GetJasonAtt("", CurrentProcessName);

            $("#fld_OTHERPAYMENT").attr("readonly", "readonly");  //设置其他支付方式为只读

            $(":input[id^=fld_detail_PROC_PO_DT][type!=button][type!=submit]").each(function () {
                $(this).attr("AutoWidth", "true");
            });
            $(":input[AutoWidth=true]").each(function (i) {
                //alert(i);
                var oWidth = $(this).parent().width();
                $(this).bind("focus", function () {
                    //alert($(this).parent().width(200));
                    $(this).parent().width(200);
                });
                $(this).bind("blur", function () {
                    //alert($(this).parent().width(200));
                    $(this).parent().width(oWidth);
                });
            })
        });
        function CheckSelect(ID) {

            //$("#fld_MATERIALTYPE").val($("#" + ID + "").val());

            $("#" + ID).parent().parent().find("[id$=fld_MATERIALTYPE]").val($("#" + ID + "").val());

        }
        function CheckSelectCostCategory(ID) {
            $("#" + ID).parent().parent().find("[id$=fld_COSTCATEGORY]").val($("#" + ID + "").val());
        }

        function SetPayment(SelectValue) {
            if ($("#" + SelectValue + "").val() == "0") {
                $("#fld_OTHERPAYMENT").removeAttr("readonly");
            }
            else {
                $("#fld_OTHERPAYMENT").attr("readonly", "readonly");
            }
            GetPaymentName($("#" + SelectValue + "").val());
        }

        function SetMaterialName(ID) {
            $("#hfResult").val("1");
            //alert($("#" + ID + "").find("option:selected").text());
            $("#" + ID).parent().parent().find("[id$=fld_MATERIALNAME]").val($("#" + ID + "").find("option:selected").text());
        }

        //判断当前输入的金额是否已超支
        var ResultCou = 0;
        function IsOverspend() {
            var objCurrAmount = $("input[id*=fld_TOTALCOST]");            //明细行申请金额
            var objCurrBalance = $("input[id*=fld_PRAMOUNT]");           //明细行PR余额                    
            if (objCurrAmount != null || objCurrAmount != undefined) {
                for (var i = 0; i < objCurrAmount.length; i++) {
                    var Am = parseFloat($("#" + objCurrAmount[i].id + "").val());
                    var Ba = parseFloat($("#" + objCurrBalance[i].id + "").val());
                    if (Am > Ba) {
                        var cou = i + 1;  //当前超支行
                        var LineValue = "The Amount of Your Current Input Has Been Overrun / 您当前输入的金额已超支";
                        $("#txtMessage").text(LineValue);
                        ResultCou = 1;
                        break;  //终止循环
                    }
                    else {
                        $("#txtMessage").text("");
                        ResultCou = 0;
                    }
                }
            }
        }

        //        function SetValue(ID) {
        //            GetJason(ID);
        //        }

        //根据用户选择的多个PR单号，用Jason返回多个单号相对应的FormID
        function GetJason(selectValue) {
            var Json = "";
            $.ajaxSetup({ async: false });
            $.get("Dialogs/GetPRMessage.ashx", { PRDoc: selectValue }, function (data) {
                var arr = eval(data);
                Json = arr;
            })

            var strFormID = "";
            if (Json != undefined) {         //判断返回值不等于空
                $.each(Json, function (i, item) {
                    strFormID = (i, item.FormID);
                    i++;
                });
            }
            $("#fld_PRFORMID").val(strFormID);
            //alert(strFormID);
        }

        //根据用户选择的付款代号，用Jason返回相对应的付款账号名称
        function GetPaymentName(selectValue) {
            var Json = "";
            $.ajaxSetup({ async: false });
            $.get("Dialogs/GetPaymentMessage.ashx", { Pay: selectValue }, function (data) {
                var arr = eval(data);
                Json = arr;
            })

            var strPayment = "";
            if (Json != undefined) {         //判断返回值不等于空
                $.each(Json, function (i, item) {
                    strPayment = (i, item.PaymentName);
                    i++;
                });
            }
            $("#fld_OTHERPAYMENT").val(strPayment);
        }

        //获取应纳税下拉值
        function CheckSelectTaxable(ID) {
            $("[id*=fld_TAXABLE]").val($(ID).val());
        }
        //获取应纳税下拉值
        function SetTaxableValue(etc) {
            $("[id*=fld_TAXABLE]").val(etc);
        }

        //获取税别下拉值
        function CheckSelectTax(ID) {
            $("[id*=fld_TAXCATEGORY]").val($(ID).val());
        }
        //获取税别下拉值
        function SetTaxValue(etc) {
            $("[id*=fld_TAXCATEGORY]").val(etc);
        }

        //用Jason返回需要用户上传的附件名
        function GetJasonAtt(selectValue, CurrentProcessName) {
            var JsonAtt = "";
            $.ajaxSetup({ async: false });
            $.get("/../../Processes/CapexProcess/Dialogs/GetAttachmentName.ashx", { Reason: selectValue, ProcessName: CurrentProcessName }, function (data) {
                var arr = eval(data);
                JsonAtt = arr;
            })

            var strAttEngListName = "";
            if (JsonAtt != undefined) {         //判断返回值不等于空
                $.each(JsonAtt, function (i, item) {
                    strAttEngListName = (i, item.AttEngListName);
                    i++;
                });
            }
            $("#lb_AttEngListName").show();   //显示要上传的文件描述
            $("#lb_AttEngListName").text("Note：Please Upload " + strAttEngListName + " the File");
            //alert(strAttEngListName);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="fld_PRFORMID" runat="server" Style="display: none"></asp:TextBox>
    <asp:TextBox ID="fld_CATEGORY" runat="server" Style="display: none"></asp:TextBox>
    <asp:TextBox ID="fld_SUBCATEGORIES" runat="server" Style="display: none"></asp:TextBox>
    <asp:LinkButton ID="lnk_LoadPayMent" runat="server" OnClick="lnk_LoadPayMent_Click"></asp:LinkButton>
    <asp:HiddenField ID="hfPRQty" runat="server" />
    <asp:HiddenField ID="hfPRUsedQty" runat="server" />
      <asp:HiddenField ID="hfCurrFormID" runat="server" />
    <div class="container">
        <div class="row">
            <ui:userinfo id="UserInfo1" processtitle="Purchasing Order<br/>采购单" processprefix="PO"
                tablename="PROC_PO" tablenamedetail="PROC_PO_DT" runat="server">
            </ui:userinfo>
        </div>
        <div class="row">
            <table class="table table-condensed table-bordered">
                <tr>
                    <td class="banner" colspan="6">
                        Application Details / 详细信息
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        PO Type:/PO 类型
                    </td>
                    <td class="td-content" colspan="4">
                        <asp:RadioButton ID="fld_CAPEXTYPE" runat="server" GroupName="Type" Text="Capex Class/固定资产类" />
                        <asp:RadioButton ID="fld_EXPENSETYPE" runat="server" GroupName="Type" Text="Expense Class/费用类" />
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        Purchasing Requisition Number/PR单号<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_PONO" runat="server" CssClass="validate[required]" disInput="true">
                        </asp:TextBox>
                        <asp:Button ID="Button1" runat="server" Text="" Width="10%" Height="25px" CssClass="btn"
                            OnClientClick="return selectPage1();" />
                    </td>
                    <td class="td-label">
                        Item Number/项目号
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_PROJECTNUMBER" runat="server" CssClass="validate[required]"
                            disInput="true"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        Supplier Number/供应商编号<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_SUPPLIERNUMBER" runat="server" CssClass="validate[required]"
                            disInput="true"></asp:TextBox>
                        <asp:Button ID="Button2" runat="server" Text="" Width="10%" Height="25px" CssClass="btn"
                            OnClientClick="return selectPage2();" />
                    </td>
                    <td class="td-label">
                        Supplier Name/供应商名称<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_SUPPLIERNAME" runat="server" CssClass="validate[required]"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        Supplier Phone/供应商电话
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_SUPPLIERPHONE" runat="server">
                        </asp:TextBox>
                    </td>
                    <td class="td-label">
                        Contact/联系人
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_CONTACT" runat="server">
                        </asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <%--<td class="td-label">
                        Buyer/采购员
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_BUYER" runat="server"  disInput="true">
                        </asp:TextBox>
                    </td>--%>
                    <td class="td-label">
                        Payment Term/付款方式<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:DropDownList ID="fld_PAYMENT" runat="server" AppendDataBoundItems="true"  onchange="SetPayment(this.id)">
                       <%--OnPreRender="fld_PAYMENT_PreRender"--%>
                        <asp:ListItem Selected="True"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td class="td-label">
                        Payment Term Name/<br />
                        付款方式名称<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_OTHERPAYMENT" runat="server">
                        </asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        Supplier E-Mial/供应商电子邮件
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_SUPPLIEREMAIL" runat="server">
                        </asp:TextBox>
                    </td>
                    <td class="td-label">
                        Currency/币种
                    </td>
                    <td class="td-content">
                        <asp:DropDownList ID="fld_CURRENCY" runat="server" CssClass="validate[required]">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                <td class="td-label">
                        Taxable/应纳税
                    </td>
                    <td class="td-content">
                        <asp:DropDownList ID="fld_TAXABLE" runat="server" CssClass="validate[required]" onchange="CheckSelectTaxable(this);">
                            <asp:ListItem Selected="True" Value="">--请选择应纳税信息--</asp:ListItem>
                            <asp:ListItem Value="Yes" Text="Yes">Yes</asp:ListItem>
                            <asp:ListItem Value="No" Text="No">No</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td class="td-label">
                        Tax Category/税别
                    </td>
                    <td class="td-content">
                        <asp:DropDownList ID="fld_TAXCATEGORY" runat="server" CssClass="validate[required]"
                            onchange="CheckSelectTax(this);">
                        </asp:DropDownList>
                    </td>                    
                </tr>
                <%--  <tr style=" display:none">--%>
                <asp:Button ID="Button3" runat="server" Text="Button" OnClick="Button3_Click" />
                <%-- </tr>--%>
            </table>
        </div>
        <div>
            <span style="float: left; color: Red">
                <asp:Label ID="txtMessage" runat="server" />
            </span>
            <tr>
                <td colspan="6">
                    <table class="table table-condensed table-bordered tablerequired" id="tbDetail">
                        <tr>
                            <th>
                                No.
                            </th>
                            <th style="width: 60px">
                                Paart No.<br /> 品号
                            </th>
                            <th style="width: 250px">
                                Part Name<br />
                                <span class="red">*</span> 品名
                            </th>
                            <th style="width: 50px; display: none">
                                Spec<br />
                                规格
                            </th>
                            <th style="width: 180px">
                                Material Type<br />
                                物料类型
                            </th>
                            <th style="width: 65px">
                                Cost Category<br />
                                成本类别
                            </th>
                            <th style="width: 185px">
                                Brand & Model<br />
                                品牌&型号
                            </th>
                            <th style="width: 95px; display:none">
                                Deadline Date<br />
                                截止日期
                            </th>
                              <th style="width: 40px">
                                Taxable<br />
                                应纳税
                            </th>
                            <th style="width: 100px">
                                Tax<br />
                                税别
                            </th>                          
                            <th style="width: 50px">
                                <%--Shortfall<br />--%>
                                Quantity<br />
                                <span class="red">*</span> 数量
                            </th>
                            <th style="width: 45px">
                                UM<br />
                                单位
                            </th>
                            <th style="width: 165px">
                                Unit Price<br />
                                <span class="red">*</span> 单价
                            </th>
                            <th style="width: 165px">
                                Total Cost<br />
                                小计
                            </th>
                            <th style="width: 60px">
                                <asp:Button ID="btnAdd" runat="server" Text="增加" CssClass="btn" CausesValidation="false"
                                    OnClick="btnAdd_Click" OnClientClick="return Check_PONO();" />
                            </th>
                        </tr>
                        <asp:Repeater ID="fld_detail_PROC_PO_DT" runat="server" OnItemCommand="fld_detail_PROC_PO_DT_ItemCommand"
                            OnPreRender="fld_detail_PROC_PO_DT_PreRender">
                            <ItemTemplate>
                                <tr>
                                    <td>
                                        <asp:Label ID="fld_ID" Text='<%# Container.ItemIndex+1 %>' runat="server" Width="20%"></asp:Label>
                                    </td>
                                    <td>
                                         <asp:TextBox ID="fld_PARTNO" Text='<%#Eval("PARTNO") %>' runat="server" Width="80%"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="fld_FORMID" Text='<%#Eval("FORMID") %>' runat="server" Style="display: none"></asp:TextBox>
                                        <asp:TextBox ID="fld_SPEC" Text='<%#Eval("SPEC") %>' runat="server" disInput="true"
                                            Width="75%" Style="display: none"></asp:TextBox>
                                        <%--规格--%>
                                        <asp:DropDownList ID="ddl_MATERIALNAME" runat="server" Width="105%" CssClass="validate[required]"
                                            AppendDataBoundItems="true" OnSelectedIndexChanged="ddlMaterial_SelectedIndexChanged"
                                            AutoPostBack="true" onchange="SetMaterialName(this.id)">
                                        </asp:DropDownList>
                                        <asp:TextBox ID="fld_MATERIALNAME" Text='<%#Eval("MATERIALNAME") %>' runat="server"
                                            Width="45%" Style="display: none"></asp:TextBox>
                                        <asp:TextBox ID="fld_BUDGETNUMBER" runat="server" Text='<%#Eval("BUDGETNUMBER") %>'
                                            Width="45%" CssClass="validate[required]" Style="display: none"></asp:TextBox>
                                        <asp:HiddenField ID="hfID" runat="server" />
                                    </td>
                                    <%-- <td>
                                        <asp:TextBox ID="fld_SPEC" Text='<%#Eval("SPEC") %>' runat="server" disInput="true"
                                            Width="75%" CssClass="validate[required]" Style=" display:none"></asp:TextBox>
                                    </td>--%>
                                    <td>
                                        <%--<asp:DropDownList ID="ddl_MATERIALTYPE" runat="server" Width="99%" CssClass="validate[required]"
                                            onchange="CheckSelect(this.id);">
                                        </asp:DropDownList>--%>
                                        <asp:TextBox ID="fld_MATERIALTYPE" Text='<%#Eval("MATERIALTYPE") %>' runat="server"
                                            Width="87%" CssClass="validate[required]" onclick="OpenMaterialTypeDialogs(this,this.id)"></asp:TextBox>
                                    </td>
                                    <td>
                                        <%--<asp:DropDownList ID="COSTCATEGORY" runat="server" Width="95%" CssClass="validate[required]"
                                            onchange="CheckSelectCostCategory(this.id);">
                                            <asp:ListItem Selected="True" Value="">--请选择成本类别信息--</asp:ListItem>
                                            <asp:ListItem Value="Repeatable" Text="Repeatable">Repeatable</asp:ListItem>
                                            <asp:ListItem Value="Discrete" Text="Discrete">Discrete</asp:ListItem>
                                        </asp:DropDownList>--%>
                                        <asp:TextBox ID="fld_COSTCATEGORY" Text='<%# Eval("COSTCATEGORY") %>' runat="server"
                                            Width="80%" onclick="OpenCostCategoryDialogs(this,this.id)"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="fld_BRANDMODEL" Text='<%#Eval("BRANDMODEL") %>' runat="server" Width="90%"></asp:TextBox>
                                    </td>
                                    <td style=" display:none">
                                        <asp:TextBox ID="fld_DEADLINEDATE" Text='<%# ProcessControl.Format.GetDate(Eval("DEADLINEDATE")) %>'
                                            runat="server" Width="85%" OnClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" disInput="true"></asp:TextBox>
                                    </td>
                                    <td>
                                       <%-- <asp:DropDownList ID="TAXABLE" runat="server" Width="100%" CssClass="validate[required]"
                                            Visible="false">
                                        </asp:DropDownList>--%>
                                        <asp:TextBox ID="fld_TAXABLE" Text='<%# Eval("TAXABLE") %>' runat="server" Width="80%"
                                            onclick="OpenTaxableDialogs(this,this.id)"></asp:TextBox>
                                    </td>
                                    <td>
                                        <%--<asp:DropDownList ID="TAX" runat="server" Visible="false">
                                        </asp:DropDownList>--%>
                                        <asp:TextBox ID="fld_TAXCATEGORY" Text='<%# Eval("TAXCATEGORY") %>' runat="server"
                                            CssClass="validate[required] ReturnValue" Width="80%" onclick="OpenTaxDialogs(this,this.id)"></asp:TextBox>
                                    </td>                                    
                                    <td>
                                        <asp:TextBox ID="fld_SHORTFALL" Text='<%#Eval("SHORTFALL") %>' runat="server" Width="80%"
                                            CssClass="validate[required]" onblur="getSumJE()" onkeyup="getSumJE()"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="fld_METER" Text='<%#Eval("METER") %>' runat="server" Width="65%"  onclick="OpenUMDialogs(this,this.id)"></asp:TextBox>                                        
                                    </td>
                                    <td>
                                        <asp:TextBox ID="fld_UNITCOST" Text='<%#Eval("UNITCOST") %>' runat="server" Width="80%"
                                            CssClass="validate[required]" onblur="getSumJE()" onkeyup="getSumJE()"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="fld_TOTALCOST" Text='<%#Eval("TOTALCOST") %>' disInput="true" runat="server"
                                            Width="80%"></asp:TextBox>
                                    </td>
                                    <td style="display: none">
                                        <asp:TextBox ID="fld_PRAMOUNT" Text='<%#Eval("PRAMOUNT") %>' runat="server" Style="display: none"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:Button ID="btnDelete" runat="server" Text="Delete/删除" CssClass="btn" CommandName="del"
                                            ClientIDMode="Static" OnClientClick="getSumJE();return confirm('Confirm Delete/确认删除？');" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                        
                                    </td>
                                    <td style="background-color: #f5f5f5">
                                        Receipted By WH？/是否需要仓库收货？
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="fld_ISRECEIPTED" runat="server" Width="105%" CssClass="validate[required]">
                                            <asp:ListItem Selected="True" Value="">--请选择--</asp:ListItem>
                                            <asp:ListItem Value="Yes" Text="Yes">Yes</asp:ListItem>
                                            <asp:ListItem Value="No" Text="No">No</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                    <td class="td-label">
                                        PR Info./<br />
                                        PR单信息
                                    </td>
                                    <td colspan="8">
                                        <asp:TextBox ID="fld_PRINFO" runat="server" Width="98%" Text='<%#Eval("PRINFO") %>' />
                                        <asp:TextBox ID="fld_PRREQUESTER" runat="server" Text='<%#Eval("PRREQUESTER") %>' style=" display:none" />
                                        <asp:TextBox ID="fld_PRREQUESTERACCOUNT" runat="server" Text='<%#Eval("PRREQUESTERACCOUNT") %>'  style=" display:none"  />
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                      <td>
                                        <%--Fin Info.<br/>财务信息--%>
                                    </td>
                                    <td class="td-label">
                                        主科目
                                    </td>
                                    <td>
                                        <asp:TextBox ID="fld_MAINSUBJECT" Text='<%#Eval("MAINSUBJECT") %>' runat="server"
                                            Width="87%" />
                                    </td>
                                    <td class="td-label">
                                        子科目
                                    </td>
                                    <td colspan="2">
                                        <asp:TextBox ID="fld_SUBACCOUNT" Text='<%#Eval("SUBACCOUNT") %>' runat="server" Width="90%" />
                                    </td>
                                    <td class="td-label">
                                        成本中心
                                    </td>
                                    <td colspan="2">
                                        <asp:TextBox ID="fld_COSTCENTER" Text='<%#Eval("COSTCENTER") %>' runat="server" Width="90%" />
                                    </td>
                                    <td class="td-label">
                                        项目号
                                    </td>
                                    <td colspan="2">
                                        <asp:TextBox ID="fld_ITEMNUMBER" Text='<%#Eval("ITEMNUMBER") %>' runat="server" Width="90%" />
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    合计：
                    <asp:TextBox ID="fld_TOTALAMOUNT" runat="server" Style="border: 0px; background-color: White;
                        display: none"></asp:TextBox>
                    <asp:TextBox ID="var_AMOUNT" runat="server" Style="border: 0px; background-color: White;"></asp:TextBox>
                </td>
            </tr>
        </div>
        <div>
            <span class="left"><font color="red">
                <asp:Label ID="lb_AttEngListName" runat="server" Text=""></asp:Label></font></span>
        </div>
        <div align="center" style="text-align: left">
            <attach:attachments id="Attachments1" runat="server">
            </attach:attachments>
        </div>
        <div align="center" style="text-align: left">
            <ah:approvalhistory id="ApprovalHistory1" showaction="false" runat="server">
            </ah:approvalhistory>
        </div>
        <div align="center" style="text-align: left">
            <btn:buttonlist id="ButtonList1" runat="server">
            </btn:buttonlist>
        </div>
    </div>
    <div id="DivShow">
    </div>
    <div style="display: none">
        <asp:HiddenField ID="hfResult" runat="server" />
    </div>
    </form>
</body>
</html>
<link href="../../App_Themes/Default/smoothness/jquery-ui-1.8.4.custom.css" type="text/css"
    rel="Stylesheet" />
<%--<script type="text/javascript" src="../../js/jquery-1.4.2.min.js" charset="gb2312"></script>
<script src="../../js/jquery-ui-1.8.4.custom.min.js" type="text/javascript" charset="gb2312"></script>--%>
<script type="text/javascript">
    //初始化Div层
    function InitDivDialogs() {
        jQuery.noConflict();    //处理JS不兼容的问题
        $("#DivShow").dialog(
            {
                modal: true,
                autoOpen: false,
                height: 200,
                width: 450,
                resizable: false,
                overlay: { overflow: 'auto' }
            }
         );
    }

    //打开应纳税页面
    var TaxableGlobal = "";
    function OpenTaxableDialogs(ert, TaxableClientID) {
        var Tax = $(ert).parent().parent().find("[id*=fld_TAXABLE]").val();
        //alert(Tax);
        TaxableGlobal = TaxableClientID;
        $("DivShow").empty();
        var url = "Dialogs/TaxAble.aspx?TxtValue=" + Tax;
        var str = "<iframe id='iframeDialogs' src='" + url + "' height='100%' width='100%' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'></iframe>";
        $("#DivShow").html(str);
        $("#DivShow").dialog("open");
        return false;
    }
    function ReturnTaxable(SelectValue) {
        if (TaxableGlobal) {
            $("#" + TaxableGlobal).val(SelectValue);
        }
    }

    //打开单位页面
    var UMGlobal = "";
    function OpenUMDialogs(ert, UMClientID) {
        var Tax = $(ert).parent().parent().find("[id*=fld_METER]").val();
        //alert(Tax);
        UMGlobal = UMClientID;
        $("DivShow").empty();
        var url = "Dialogs/UM.aspx?TxtValue=" + Tax;
        var str = "<iframe id='iframeDialogs' src='" + url + "' height='100%' width='100%' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'></iframe>";
        $("#DivShow").html(str);
        $("#DivShow").dialog("open");
        return false;
    }
    function ReturnUM(SelectValue) {
        if (UMGlobal) {
            $("#" + UMGlobal).val(SelectValue);
        }
    }

    //打开税别页面
    var TaxGlobal = "";
    function OpenTaxDialogs(ert, TaxClientID) {
        var Tax = $(ert).parent().parent().find("[id*=fld_TAXCATEGORY]").val();
        //alert(TaxClientID);
        TaxGlobal = TaxClientID;
        $("DivShow").empty();
        var url = "Dialogs/Tax.aspx?TxtValue=" + Tax;
        var str = "<iframe id='iframeDialogs' src='" + url + "' height='100%' width='100%' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'></iframe>";
        $("#DivShow").html(str);
        $("#DivShow").dialog("open");
        return false;
    }

    //返回弹出层中税别选中的值
    function ReturnTaxCategory(SelectValue) {
        if (TaxGlobal) {
            $("#" + TaxGlobal).val(SelectValue);
        }
    }

    //打开物料类型页面
    var MaterialTypeGlobal = "";
    function OpenMaterialTypeDialogs(ert, MaterialTypeClientID) {
        var MaterialType = $(ert).parent().parent().find("[id*=fld_MATERIALTYPE]").val();
        MaterialTypeGlobal = MaterialTypeClientID;
        $("DivShow").empty();
        var url = "Dialogs/MaterialType.aspx?TxtValue=" + MaterialType;
        var str = "<iframe id='iframeDialogs' src='" + url + "' height='100%' width='100%' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'></iframe>";
        $("#DivShow").html(str);
        $("#DivShow").dialog("open");
        return false;
    }

    //返回弹出层中物料类型选中的值
    function ReturnMaterialType(SelectValue) {
        if (MaterialTypeGlobal) {
            $("#" + MaterialTypeGlobal).val(SelectValue);
        }
    }

    //打开成本类别页面
    var CostCategoryGlobal = "";
    function OpenCostCategoryDialogs(ert, CostCategoryClientID) {
        var CostCategory = $(ert).parent().parent().find("[id*=fld_COSTCATEGORY]").val();
        CostCategoryGlobal = CostCategoryClientID;
        $("DivShow").empty();
        var url = "Dialogs/CostCategory.aspx?TxtValue=" + CostCategory;
        var str = "<iframe id='iframeDialogs' src='" + url + "' height='100%' width='100%' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'></iframe>";
        $("#DivShow").html(str);
        $("#DivShow").dialog("open");
        return false;
    }

    //返回弹出层中成本类别选中的值
    function ReturnCostCategory(SelectValue) {
        if (CostCategoryGlobal) {
            $("#" + CostCategoryGlobal).val(SelectValue);
        }
    }

    //关闭通过DIV层打开的对话框
    function DivDialogClose(retValue) {
        $("#DivShow").dialog("close");
    }


</script>
